//app.js
App({
  onLaunch: function () {
    //调用API从本地缓存中获取数据 
    var logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)
   
  },
  getUserInfo:function(cb){
    var that = this //闭包技术，匿名函数
    if(this.globalData.userInfo){
      typeof cb == "function" && cb(this.globalData.userInfo)
    }else{ 
      //调用登录接口
      wx.login({
        success: function () {
          wx.getUserInfo({
            success: function (res) {
              that.globalData.userInfo = res.userInfo
              typeof cb == "function" && cb(that.globalData.userInfo)
            }
          })
        }
      })
    }
  },

  loginFun(userinfo) {
    let self = this;
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
        self.globalData.longinCode = res.code;

      }
    })
  },

  
  /**
   * http://www.wxapp-union.com/forum.php?mod=viewthread&tid=1248&extra=page%3D1 小程序多个体验者配置
   */
  globalData:{
    userInfo:null,
    user:null,
    cookie: ''
  },
  GLOBAL_CONFIG:{
  //  'commonUrl':'http://127.0.0.1:8080/epm',//网址
    //  'commonUrl': 'http://10.194.0.183:8080/epm',
    'commonUrl': 'https://mis.ynyourband.com:8080/epm',
    // 'commonUrl': 'https://mis.ynyourband.com',
    'loginUrl':'/project/miniprogram/loginInWxAction.do',//登录
    'signTaskUrl':'/project/miniprogram/claim.do',//签收
    'todoListJSONUrl':'/project/miniprogram/todoListJSON.do',//待办流程
    'historicJSONUrl':'/project/miniprogram/historicJSON.do',//已完成流程
    'todoBusinessTaskUrl':'/project/miniprogram/myBusinessTaskListJSON.do?status=0&status=3',//待办任务
    'historicBusinessTaskUrl':'/project/miniprogram/myBusinessTaskListJSON.do?status=2',//已完成任务 
    'historicFlowView':'/project/miniprogram/histoicFlow.do',//已完成流程历史跟踪
    'taskDetail':'/project/miniprogram/form.do',   //业务审批界面
    'businessTaskDetail':'/project/miniprogram/businessTaskHandle.do',//待办业务详情
    'businessTaskHandle':'/project/miniprogram/handleAction.do',//待办业务办理
    'businessTaskConfirm':'/project/miniprogram/confirmFinishedAction.do',//任务确认完成
    'getOrgAllUser':'/sys/companyUser/getOrgAllUserGridData.do',//获取用户
    'logout': '/sys/logoutInWxAction.do',//退出登录
    'uploadFile': '/project/miniprogram/uploadAction.do'//上传附件
    
  } 
})   